import {ref} from 'vue'

export default function addTodo(){

  let txt = ref<string>('') //输入的文本
  // 添加
  // 
  let count=ref(1);
  let add = () => {
    if(!localStorage.todo){
      localStorage.todo = JSON.stringify([])
    }
    let arr=JSON.parse(localStorage.todo)
    console.log(arr._value)
    arr._value.push({
      id: new Date().getTime(),
      text: txt.value,
      isDone: false
    })
    localStorage.todo = JSON.stringify(arr)
    count.value++
  }
  return {
    txt,
    count,
    add
  }
}